package com.yy.tech.data;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.yy.tech.data.context.SecretContent;
import com.yy.tech.data.helper.DesensitizeHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.env.Environment;

import java.text.SimpleDateFormat;

/**
 *
 */
@Configuration
@ComponentScan
@ConditionalOnProperty(value = SecretContent.KEY_DESENSITIZE_ENABLE,havingValue = "true")
public class DesensitizedConfiguration {

    @Autowired
    private DesensitizeHelper helper;

    @Bean(SecretContent.DESENSITIZE_OBJECT_MAPPER)
    @ConditionalOnMissingBean(name = SecretContent.DESENSITIZE_OBJECT_MAPPER)
    public ObjectMapper desensitizeObjectMapper(){
        return helper.help();
    }

}
